<template>
    <div class="app-container">

        <el-input
                placeholder="输入关键字进行过滤"
                v-model="filterText">
        </el-input>

        <el-tree
                class="filter-tree"
                :data="data2"
                :props="defaultProps"
                default-expand-all
                :filter-node-method="filterNode"
                ref="tree2">
        </el-tree>


        <pagination-component ref="pagination" v-on:getList="getList"></pagination-component>
    </div>
</template>
<style>
    .demo-table-expand {
        font-size: 0;
    }
    .demo-table-expand label {
        width: 90px;
        color: #99a9bf;
    }
    .demo-table-expand .el-form-item {
        margin-right: 0;
        margin-bottom: 0;
        width: 50%;
    }
</style>
<script>
    import PaginationComponent from '../common/pagination-component.vue';
    export default {
        components: {
            'pagination-component': PaginationComponent,
        },
        watch: {
            filterText(val) {
                this.$refs.tree2.filter(val);
            }
        },

        methods: {
            filterNode(value, data) {
                if (!value) return true;
                return data.label.indexOf(value) !== -1;
            }
        },
        data() {
            return {
                filterText: '',
                data2: [],
                defaultProps: {
                    children: 'alls',
                    label: 'phone'
                }
            }
        },
        mounted() {
            window._this = this;
            window._this.getList();
        },
        methods: {
            getList() {
                let paramsData = { 'data': { 'search': ''} };
                axios.get('/backend/user/particulars/'+window._this.$route.params.id+'?page=' + window._this.$refs.pagination.pageData.current_page, { params: paramsData }).then(response => {
                    let {status, data, message} = response.data;
                    window._this.data2 = data.data;
                    window._this.$refs.pagination.pageData.per_page = parseInt(data.per_page);
                    window._this.$refs.pagination.pageData.current_page = parseInt(data.current_page);
                    window._this.$refs.pagination.pageData.total = parseInt(data.total);
                })
            },






        }
    }
</script>